package com.examples.demo4.write;

import com.examples.demo4.api.MyApplet;
import com.examples.demo4.api.MyDestination;
import com.examples.demo4.api.Output;
import com.examples.demo4.api.StringProvider;
import com.google.inject.Inject;
import com.google.inject.Provider;

public class StringWritingApplet implements MyApplet {

    private MyDestination destination;
    private Provider<String> stringProvider;

    @Inject
    public StringWritingApplet(MyDestination destination, @Output Provider<String>  stringProvider) {
        super();
        this.destination = destination;
        this.stringProvider = stringProvider;
    }

    private void writeString() {
        destination.write(stringProvider.get());
    }

    @Override
    public void run() {
        writeString();
    }
}
